/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.camel.component.as2.api;

interface Constants {
    static final String SHA_1_AS2_ALGORITHM_NAME = "sha1";
    static final String SHA_1_JDK_ALGORITHM_NAME = "SHA-1";

    static final String MD5_AS2_ALGORITHM_NAME = "md5";
    static final String MD5_JDK_ALGORITHM_NAME = "MD5";
}

public enum AS2MicAlgorithm {
    SHA_1(Constants.SHA_1_JDK_ALGORITHM_NAME, Constants.SHA_1_AS2_ALGORITHM_NAME),
    MD5(Constants.MD5_JDK_ALGORITHM_NAME, Constants.MD5_AS2_ALGORITHM_NAME);

    private String jdkAlgorithmName;
    private String as2AlgorithmName;

    private AS2MicAlgorithm(String jdkAlgorithmName, String as2AlgorithmName) {
        this.jdkAlgorithmName = jdkAlgorithmName;
        this.as2AlgorithmName = as2AlgorithmName;
    }

    public String getJdkAlgorithmName() {
        return jdkAlgorithmName;
    }

    public String getAs2AlgorithmName() {
        return as2AlgorithmName;
    }

    public static String getJdkAlgorithmName(String as2AlgorithmName) {
        switch(as2AlgorithmName) {
        case Constants.SHA_1_AS2_ALGORITHM_NAME:
            return Constants.SHA_1_JDK_ALGORITHM_NAME;
        case Constants.MD5_AS2_ALGORITHM_NAME:
            return Constants.MD5_JDK_ALGORITHM_NAME;
        default:
            return null;
        }
    }

    public static String getAS2AlgorithmName(String jdkAlgorithmName) {
        switch(jdkAlgorithmName) {
        case Constants.MD5_JDK_ALGORITHM_NAME:
            return Constants.MD5_AS2_ALGORITHM_NAME;
        case Constants.SHA_1_JDK_ALGORITHM_NAME:
            return Constants.SHA_1_AS2_ALGORITHM_NAME;
        default:
            return null;
        }
    }

}
